-- @owner: zou_jialiang050
-- @date: 2024/4/2
-- @testpoint: pipelined函数,返回多个pipelined，合理报错

--step1:create package创建管道函数，返回多个pipelined标志;expect:合理报错
CREATE OR REPLACE PACKAGE pkg0016 AS
    TYPE array_type_0016_1 AS varray(10) OF char(10);
    FUNCTION func_pipelined_0016(count NUMBER) RETURN array_type_0016_1 pipelined pipelined;
END pkg0016;
/

CREATE OR REPLACE PACKAGE BODY pkg0016 AS
    FUNCTION func_pipelined_0016(count NUMBER) RETURN array_type_0016_1 pipelined pipelined IS
	declare result array_type_0016_1;
        BEGIN
            FOR i IN 1..count LOOP
                result := array[1, 2, 4, 5 ];
				pipe row(result[i]);
            END LOOP;
            RETURN;
        END;
END pkg0016;
/

--step2:创建管道函数，返回多个pipelined标志;expect:合理报错
create or replace type tb_type_00019 as table of tinyint;
create or replace function func_pipelined_0019(count in number)
returns tb_type_00019 pipelined pipelined
as $$
declare result integer;
begin
for i in 1 .. count loop
pipe row(12);
end loop;
return;
end;
$$ language plpgsql;
/

--step3:清理环境;expect:成功
drop type tb_type_00019;
